#pragma once

#include <algorithm>
#include <string>
#include <vector>

#include <catch2/catch.hpp>

namespace jianzhi_045
{

class Solution
{
public:
    std::string minNumber(const std::vector<int>& nums)
    {
        std::vector<std::string> num_str;
        for (auto v : nums)
            num_str.push_back(std::to_string(v));
        std::sort(num_str.begin(), num_str.end(),
                [](const std::string& a, const std::string& b)
                {
                    if (a.size() == b.size())
                        return a < b;
                    return a + b < b + a;
                });
        for (int i = 1; i < (int)num_str.size(); ++i)
            num_str.front() += num_str.at(i);
        return num_str.front();
    }
};

}  /* namespace jianzhi_045 */
